Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

178
Views
Normalization and Denormalization MongoDB | Schema Question Follow System

I'm breaking my head over this:

The User on my WebApp can follow a Tag (Like a user can follow a subreddit), the followed Tag will be shown in the Homepage with a different color than the not followed one. If a User follows a Tag he will get Push-Notifications when a new Blog Post is published tagged with the Tag.

So I have to query for all the tags a given user follows.

And I have to query for all the user which follow a given tag.

A user can follow max 20 Tags. Since I have a Many to Many relation should i go with something like this (normalization)

const SubscribeToTagSchema = new Mongoose.Schema({
 user: {
  type: Schema.Types.ObjectId,
  ref: "User",
  required: true,
 },
 tag: {
  type: Schema.Types.ObjectId,
  ref: "Tag",
  required: true,
 },
});

or should I just save the data in both schema User and Tag?

const UserSchema = new Mongoose.Schema({
 tag: {
  type: Schema.Types.ObjectId,
  ref: "Tag",
  required: true,
 },
});

const TagSchema = new Mongoose.Schema({
 user: {
  type: Schema.Types.ObjectId,
  ref: "User",
  required: true,
 },
});
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!